# -*- coding: utf-8 -*-
# @Time: 2021/11/27 13:15
# @Author: lijinxi
# @File    : acceptance_computation_ratio.py
# @desc
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator
from scipy.interpolate import make_interp_spline
import numpy as np
# 实现插值的模块
from scipy import interpolate
# 画图的模块
import matplotlib.pyplot as plt

X = [0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0]
Y = [-0.0, 12.0, 35.0, 51.0, 63.0, 75.0, 86.0, 97.0, 106.0, 116.0, 125.0, 134.0, 140.0, 134.0, 127.0, 118.0, 109.0,
     99.0, 85.0, 67.0, 50.0]

X, Y = np.array(X), np.array(Y) / 200

func = interpolate.interp1d(X, Y, kind='cubic')
x_new = np.linspace(0, 2, 100)
y_new = make_interp_spline(X, Y)(x_new)
plt.plot(x_new, y_new, ls='-', color='g', linewidth=2)
plt.tick_params(axis='both', which='major', labelsize=18)
plt.xlabel(r'$\alpha$', fontsize=18)
plt.ylabel('Acceptance Ratio', fontsize=18)
x_major_locator = MultipleLocator(0.2)

y_major_locator = MultipleLocator(0.2)
ax = plt.gca()
ax.xaxis.set_major_locator(x_major_locator)
ax.yaxis.set_major_locator(y_major_locator)
plt.xlim(-0.1, 1)
plt.ylim(0, 1)
plt.plot([0.6, 0.60], [0, 0.7], ls='--', color='grey')
plt.plot([-0.1, 0.6], [0.7, 0.7], ls='--', color='grey')
plt.plot([-0.1, 1], [0.25, 0.25], ls='--', color='grey')
plt.xticks([0, 0.2, 0.4, 0.6, 0.8, 1])
plt.yticks([0.0, 0.25, 0.4, 0.7, 1.0])
plt.axhline(y=0.6, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=0.4, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=0.2, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=0.8, color='lightgray', ls=':', linewidth=1)
plt.legend(['NBS'], fontsize=18, frameon=False)
plt.savefig('computation_alpha.pdf', bbox_inches='tight')

plt.show()
